import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.IOException;

public class Demo {
    public static void main(String[] args) {
        try (FileInputStream fileInputStream = new FileInputStream("test.txt");
             InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {

            int data;
            while ((data = inputStreamReader.read()) != -1) {
                System.out.print((char) data);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}